home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Web Server / PHP.EXE / pear / PHPDoc / renderer / html / PhpdocHTMLDocumentRenderer.php < prev    next >
Encoding:
PHP Script  |  2001-02-22  |  25.4 KB  |  745 lines

  1. <?php
  2. /**
  3. * Provides functioninality to render modules and classes.
  4. *
  5. * @version $Id: PhpdocHTMLDocumentRenderer.php,v 1.6 2001/02/21 19:13:18 chagenbu Exp $
  6. */
  7. class PhpdocHTMLDocumentRenderer extends PhpdocHTMLRenderer {
  8.  
  9.     /**
  10.     * Message displayed if an object lacks documentation.
  11.     *
  12.     * @var      string  $undocumented
  13.     * @access   public
  14.     */
  15.     var $undocumented = "Warning: documentation is missing.";
  16.  
  17.     /**
  18.     * Array of functions found in the xml document.
  19.     *
  20.     * @var  array   $functions
  21.     */
  22.     var $functions = array();
  23.  
  24.     /**
  25.     * Array of included files.
  26.     *
  27.     * @var  array   $uses
  28.     */
  29.     var $uses = array();
  30.  
  31.     /**
  32.     * Array of constants.
  33.     *
  34.     * @var  array   $constants
  35.     */
  36.     var $constants = array();
  37.  
  38.     /**
  39.     * Array of access modifiers.
  40.     *
  41.     * @var  array   $accessModifiers
  42.     */
  43.     var $accessModifiers = array("public", "private");
  44.  
  45.     /**
  46.     * Array of doc container fields that get mapped directly to templateblocks.
  47.     *
  48.     * @var  array    $simpleDocfields
  49.     * @see  renderVariableDetail()
  50.     */    
  51.     var $simpleDocfields = array(
  52.                                 "VERSION"       => "version", 
  53.                                 "SINCE"         => "since",
  54.                                 "DEPRECATED"    => "deprecated", 
  55.                                 "COPYRIGHT"     => "copyright", 
  56.                                 "MAGIC"         => "magic" 
  57.                             );
  58.  
  59.     /**
  60.     * Types of include statements.
  61.     *
  62.     * @var  array       $usesTypes
  63.     * @see  renderUses()
  64.     */                                                            
  65.     var $usesTypes = array( "include", "include_once", "require", "require_once" );
  66.  
  67.     /**
  68.     * Adds a summary and a detailed list of all constants to the template.
  69.     *
  70.     * @see  renderConstantSummary(), renderConstantDetail()
  71.     */                                                                            
  72.     function renderConstants() {
  73.  
  74.         $this->constants["public"]  = $this->accessor->getConstantsByAccess("public");
  75.         $this->constants["private"] = $this->accessor->getConstantsByAccess("private");
  76.  
  77.         if (0 == count($this->constants["public"]) && 0 == count($this->constants["private"]))
  78.             return;
  79.  
  80.         $this->renderConstantSummary();
  81.         $this->renderConstantDetail();
  82.         $this->constants = array();
  83.  
  84.     } // end func renderConstants
  85.  
  86.     /**
  87.     * Adds a summary of all constants to the template.
  88.     *
  89.     * The function assumes that there is a block called "constantssummary" and
  90.     * withing this block a bock called "constantssummary_loop" in the template.
  91.     * 
  92.     * @see  renderConstantDetail()
  93.     */    
  94.     function renderConstantSummary() {
  95.  
  96.         reset($this->accessModifiers);
  97.         while (list($k, $access) = each($this->accessModifiers)) {
  98.             if (0 == count($this->constants[$access])) 
  99.                 continue;
  100.  
  101.             $this->tpl->setCurrentBlock("constantssummary_loop");
  102.  
  103.             reset($this->constants[$access]);
  104.             while (list($name, $const) = each($this->constants[$access])) {
  105.  
  106.                 $this->tpl->setVariable("NAME", $name);
  107.                 $this->tpl->setVariable("VALUE", htmlentities($const["value"]));            
  108.                 
  109.                 if (isset($const["doc"]["shortdescription"]))
  110.                     $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($const["doc"]["shortdescription"]["value"]));
  111.  
  112.                 if ("true" == $const["undoc"])
  113.                     $this->tpl->setVariable("UNDOC", $this->undocumented);
  114.  
  115.                 $this->tpl->parseCurrentBlock();
  116.             }
  117.  
  118.             $this->tpl->setCurrentBlock("constantssummary");
  119.             $this->tpl->setVariable("ACCESS", ucfirst($access));
  120.             $this->tpl->parseCurrentBlock();
  121.  
  122.         }
  123.  
  124.     } // end func renderConstantSummary
  125.  
  126.     /** 
  127.     * Adds a detailed list of all constants to the template.
  128.     * 
  129.     * The function assumes that there is a block named "constantdetails" and
  130.     * withing it another block named "constantdetails_loop". 
  131.     *
  132.     * @see  renderConstantSummary()
  133.     */    
  134.     function renderConstantDetail() {
  135.  
  136.         reset($this->accessModifiers);
  137.         while (list($k, $access) = each($this->accessModifiers)) {
  138.             if (0 == count($this->constants[$access]))
  139.                 continue;
  140.  
  141.             reset($this->constants[$access]);
  142.             while (list($name, $constant) = each($this->constants[$access])) {
  143.  
  144.                 $tplvars = array();
  145.                 $tplvars["NAME"]    =    $name;
  146.                 $tplvars["CASE"]    = $constant["case"];
  147.                 $tplvars["VALUE"]   =    htmlentities($constant["value"]);
  148.  
  149.                 if ("true" == $constant["undoc"])
  150.                     $tplvars["UNDOC"] = $this->undocumented;
  151.  
  152.                 if (isset($constant["doc"]["shortdescription"]))
  153.                     $tplvars["SHORTDESCRIPTION"] = $this->encode($constant["doc"]["shortdescription"]["value"]);
  154.  
  155.                 if (isset($constant["doc"]["description"]))
  156.                     $tplvars["DESCRIPTION"] = $this->encode($constant["doc"]["description"]["value"]);
  157.  
  158.                 $this->renderCommonDocfields("constantdetails_", $constant);
  159.  
  160.                 $this->tpl->setCurrentBlock("constantdetails_loop");
  161.                 $this->tpl->setVariable($tplvars);
  162.                 $this->tpl->parseCurrentBlock();
  163.             }
  164.  
  165.             $this->tpl->setCurrentBlock("constantdetails");
  166.             $this->tpl->setVariable("ACCESS", ucfirst($access));
  167.             $this->tpl->parseCurrentBlock();
  168.         }    
  169.  
  170.     } // end func renderConstantsDetail
  171.  
  172.     /**
  173.     * Adds a summary and a detailed list of included files to the template.
  174.     *
  175.     * @see  renderUsesSummary(), renderUsesDetail()
  176.     */        
  177.     function renderUses() {
  178.  
  179.         $found = false;
  180.         
  181.         reset($this->usesTypes);
  182.         while (list($k, $type) = each($this->usesTypes)) {
  183.  
  184.             $this->uses[$type] = $this->accessor->getUsesByType($type);
  185.             if (!$found && 0 != count($this->uses[$type]))
  186.                 $found = true;
  187.  
  188.         }
  189.  
  190.         if (!$found)
  191.             return;
  192.  
  193.         $this->renderUsesSummary();
  194.         $this->renderUsesDetail();
  195.  
  196.         $this->uses = array();
  197.     } // end func renderUses                                                            
  198.  
  199.     /**
  200.     * Adds a detailed list of all included files to the template.
  201.     * 
  202.     * The function assumes that there is a block names "usesdetail" and within the block 
  203.     * a block names "usesdetail_loop" in the template.
  204.     *
  205.     * @see  renderUsesSummary()
  206.     */    
  207.     function renderUsesDetail() {
  208.  
  209.         reset($this->usesTypes);
  210.         while (list($k, $type) = each($this->usesTypes)) {
  211.             if (0 == count($this->uses[$type]))
  212.                 continue;
  213.  
  214.             reset($this->uses[$type]);
  215.             while (list($file, $uses) = each($this->uses[$type])) {
  216.  
  217.                 $tplvars = array();
  218.                 $tplvars["FILE"]    = $uses["file"];
  219.                 $tplvars["TYPE"]    = $type;
  220.  
  221.                 if ("true" == $uses["undoc"])
  222.                     $tplvars["UNDOC"] = $this->undocumented;
  223.  
  224.                 if (isset($uses["doc"]["shortdescription"]))
  225.                     $tplvars["SHORTDESCRIPTION"] = $this->encode($uses["doc"]["shortdescription"]["value"]);
  226.  
  227.                 if (isset($uses["doc"]["description"]))
  228.                     $tplvars["DESCRIPTION"] = $this->encode($uses["doc"]["description"]["value"]);
  229.                 
  230.                 $this->renderCommonDocfields("usesdetails_", $uses);
  231.                 $this->tpl->setCurrentBlock("usesdetails_loop");
  232.                 $this->tpl->setVariable($tplvars);
  233.                 $this->tpl->parseCurrentBlock();
  234.             }
  235.  
  236.             $this->tpl->setCurrentBlock("usesdetails");
  237.             $this->tpl->setVariable("TYPE", $type);
  238.             $this->tpl->parseCurrentBlock();
  239.         }
  240.  
  241.     } // end func renderUsesDetail
  242.  
  243.     /** 
  244.     * Adds a summary of all included files to the template.
  245.     * 
  246.     * The function assumes that there is a block names "usessummary" and within
  247.     * the block another block names "usessummary_loop" in the template.
  248.     * 
  249.     * @see  renderUsesDetail()
  250.     */    
  251.     function renderUsesSummary() {
  252.  
  253.         reset($this->usesTypes);
  254.         while (list($k, $type) = each($this->usesTypes)) {
  255.             if (0 == count($this->uses[$type]))
  256.                 continue;
  257.  
  258.             $this->tpl->setCurrentBlock("usessummary_loop");
  259.  
  260.             reset($this->uses[$type]);
  261.             while (list($file, $uses) = each($this->uses[$type])) {
  262.  
  263.                 $this->tpl->setVariable("FILE", $file);
  264.                 if (isset($uses["doc"]["shortdescription"]))
  265.                     $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($uses["doc"]["shortdescription"]["value"]));
  266.  
  267.                 if ("true" == $uses["undoc"])
  268.                     $this->tpl->setVariable("UNDOC", $this->undocumented);
  269.  
  270.                 $this->tpl->parseCurrentBlock();
  271.             }
  272.  
  273.             $this->tpl->setCurrentBlock("usessummary");
  274.             $this->tpl->setVariable("TYPE", $type);
  275.             $this->tpl->parseCurrentBlock();
  276.         }
  277.  
  278.     } // end func renderUsesSummary
  279.  
  280.     /**
  281.     * Adds a summary and a detailed list of all functions to the template.
  282.     *
  283.     * @see  renderFunctionSummary(), renderFunctionDetail(), $functions
  284.     */
  285.     function renderFunctions() {
  286.  
  287.         $this->functions["private"] = $this->accessor->getFunctionsByAccess("private");
  288.         $this->functions["public"]  = $this->accessor->getFunctionsByAccess("public");
  289.  
  290.         if (0 == count($this->functions["private"]) && 0 == count($this->functions["public"]))
  291.             return;
  292.  
  293.         $this->renderFunctionSummary();
  294.         $this->renderFunctionDetail();
  295.         $this->functions = array();
  296.         
  297.     } // end func renderFunctions
  298.  
  299.     /**
  300.     * Adds a function summary to the template.
  301.     * 
  302.     * The function assumes that there is ablock names "functionsummary" and 
  303.     * within it a block names "functionsummary_loop" in the template. 
  304.     *
  305.     * @see  renderFunctionDetail(), renderFunctions(), $functions, $accessModifiers
  306.     */    
  307.     function renderFunctionSummary() {
  308.  
  309.         reset($this->accessModifiers);
  310.         while (list($k, $access) = each($this->accessModifiers)) {
  311.             if (0 == count($this->functions[$access])) 
  312.                 continue;            
  313.  
  314.             $this->tpl->setCurrentBlock("functionsummary_loop");
  315.             reset($this->functions[$access]);
  316.             while (list($name, $function) = each($this->functions[$access])) {
  317.  
  318.                 $this->tpl->setVariable("NAME", $name);
  319.                 
  320.                 if (isset($function["doc"]["parameter"]))
  321.                     $this->tpl->setVariable("PARAMETER", $this->getParameter($function["doc"]["parameter"]));
  322.  
  323.                 if (isset($function["doc"]["shortdescription"]))
  324.                     $this->tpl->setVariable("SHORTDESCRIPTION", $this->encode($function["doc"]["shortdescription"]["value"]));
  325.  
  326.                 if (isset($function["doc"]["return"]))
  327.                     $this->tpl->setVariable("RETURNTYPE", $function["doc"]["return"]["type"]);
  328.                 else
  329.                     $this->tpl->setVariable("RETURNTYPE", "void");
  330.  
  331.                 if ("true" == $function["undoc"])
  332.                     $this->tpl->setVariable("UNDOC", $this->undocumented);
  333.  
  334.                 $this->tpl->parseCurrentBlock();
  335.             }
  336.  
  337.             $this->tpl->setCurrentBlock("functionsummary");                
  338.             $this->tpl->setVariable("ACCESS", ucfirst($access) );
  339.             $this->tpl->parseCurrentBlock();
  340.         }
  341.  
  342.     } // end func renderFunctionSummary
  343.  
  344.     /**
  345.     * Adds a detailed list of functions to the template.
  346.     *
  347.     * The function assumes that there is a block named "functiondetails" and 
  348.     * within it a bloc "functiondetails_loop" in the template.
  349.     *
  350.     * @see  renderFunctions(), renderFunctionSummary(), $functions, $accessModifiers
  351.     */
  352.     function renderFunctionDetail() {
  353.  
  354.         reset($this->accessModifiers);
  355.         while (list($k, $access) = each($this->accessModifiers)) {
  356.             if (0 == count($this->functions[$access]))
  357.                 continue;
  358.  
  359.             reset($this->functions[$access]);
  360.             while (list($name, $function) = each($this->functions[$access])) {
  361.  
  362.                 $tplvars = array();
  363.                 $tplvars["NAME"]    = $function["name"];
  364.                 $tplvars["ACCESS"]  = $function["access"];
  365.  
  366.                 if ("true" == $function["undoc"])
  367.                     $tplvars["UNDOC"]  = $this->undocumented;
  368.  
  369.                 if ("true" == $function["abstract"])
  370.                     $tplvars["ABSTRACT"] = "abstract";
  371.  
  372.                 if ("true" == $function["static"])
  373.                     $tplvars["STATIC"] = "static";
  374.  
  375.                 if (isset($function["doc"]["shortdescription"]))
  376.                     $tplvars["SHORTDESCRIPTION"] = $this->encode($function["doc"]["shortdescription"]["value"]);
  377.  
  378.                 if (isset($function["doc"]["description"]))
  379.                     $tplvars["DESCRIPTION"] = $this->encode($function["doc"]["description"]["value"]);
  380.  
  381.                 $this->renderCommonDocfields("functiondetails_", $function);
  382.                 
  383.                 if (isset($function["doc"]["parameter"])) {
  384.                     $tplvars["PARAMETER"] = $this->getParameter($function["doc"]["parameter"]);
  385.                     $this->renderParameterDetail($function["doc"]["parameter"]);
  386.                 }
  387.                 
  388.                 if (isset($function["doc"]["throws"]))
  389.                     $this->renderThrows($function["doc"]["throws"], "functiondetails_");
  390.  
  391.                 if (isset($function["doc"]["global"])) 
  392.                     $this->renderGlobals($function["doc"]["global"], "functiondetails_");
  393.  
  394.                 if (isset($function["doc"]["return"])) {
  395.  
  396.                     $tplvars["RETURNTYPE"] = $function["doc"]["return"]["type"];                    
  397.  
  398.                     $this->tpl->setCurrentBlock("functiondetails_return");
  399.                     $this->tpl->setVariable("TYPE", $function["doc"]["return"]["type"]);
  400.                     $this->tpl->setVariable("DESCRIPTION", $this->encode($function["doc"]["return"]["value"]));
  401.  
  402.                     if (isset($function["doc"]["return"]["name"]))
  403.                         $this->tpl->setVariable("NAME", $function["doc"]["return"]["name"]);
  404.  
  405.                     $this->tpl->parseCurrentBlock();
  406.  
  407.                 } else {
  408.  
  409.                     $tplvars["RETURNTYPE"] = "void";
  410.  
  411.                 }
  412.  
  413.                 $this->tpl->setCurrentBlock("functiondetails_loop");    
  414.                 $this->tpl->setVariable($tplvars);
  415.                 $this->tpl->parseCurrentBlock();    
  416.             }
  417.  
  418.             $this->tpl->setCurrentBlock("functiondetails");
  419.             $this->tpl->setVariable("ACCESS", ucfirst($access) );
  420.             $this->tpl->parseCurrentBlock();
  421.         }
  422.  
  423.     } // end func renderFunctionDetail
  424.  
  425.     /**
  426.     * Renders a detailed list of function parameters.
  427.     *
  428.     * The function assumes that there is a block named "functiondetails_parameter" in 
  429.     * the template and within it a block named "functiondetails_parameter_loop".
  430.     *
  431.     * @param    array   Parameter
  432.     */
  433.     function renderParameterDetail($parameter) {
  434.  
  435.         if (!isset($parameter[0]))
  436.             $parameter = array($parameter);
  437.  
  438.         $this->tpl->setCurrentBlock("functiondetails_parameter_loop");
  439.         
  440.         reset($parameter);
  441.         while (list($k, $param) = each($parameter)) {
  442.  
  443.             $this->tpl->setVariable("NAME",    $param["name"]);
  444.             $this->tpl->setVariable("DESCRIPTION", $this->encode($param["value"]));
  445.  
  446.             if (isset($param["type"]))
  447.                 $this->tpl->setVariable("TYPE", $param["type"]);
  448.  
  449.             if (isset($param["default"]))
  450.                 $this->tpl->setVariable("DEFAULT", "= >>".htmlentities($param["default"])."<<");
  451.  
  452.             if ("true" == $param["undoc"])
  453.                 $this->tpl->setVariable("UNDOC", $this->undocumented);
  454.  
  455.             $this->tpl->parseCurrentBlock();            
  456.         }
  457.  
  458.     } // end func renderParameterDetail
  459.  
  460.     /**
  461.     * Converts the XML parameter array into formatted string.
  462.     *
  463.     * @param    array   XML parameter array
  464.     * @return   string  Formatted parameter string
  465.     */
  466.     function getParameter($parameter) {
  467.  
  468.         if (!is_array($parameter))
  469.             return "void";
  470.  
  471.         $value = "";
  472.  
  473.         if (!isset($parameter[0])) {
  474.  
  475.             if (!isset($parameter["default"]))
  476.                 $value .= $parameter["type"] . " " . $parameter["name"];
  477.             else
  478.                 $value .= "[ ".$parameter["type"] . " " . $parameter["name"]." ]";
  479.  
  480.         } else {
  481.  
  482.             $flag_optional = false;
  483.  
  484.             reset($parameter);
  485.             while (list($k, $param) = each($parameter)) {
  486.  
  487.                 if (!isset($param["default"])) {
  488.                     if ($flag_optional) {
  489.                         $value = substr($value, 0, -2) . " ], ";
  490.                         $flag_optional = false;
  491.                     }
  492.                 } else {
  493.                     if (!$flag_optional) {
  494.                         $value .= "[ ";
  495.                         $flag_optional = true;
  496.                     }
  497.                 }
  498.  
  499.                 $value .= $param["type"] . " " . $param["name"].", ";
  500.             }
  501.  
  502.             $value = substr($value, 0, -2);
  503.             if ($flag_optional)
  504.                 $value .= " ]";
  505.  
  506.         }
  507.  
  508.         return $value;        
  509.     } // end func getParameter
  510.  
  511.     /**
  512.     * Renders a block with references to other source elements.
  513.     *
  514.     * @param    array   XML references array
  515.     * @param    string  optional template blockname prefix
  516.     */    
  517.     function renderSee($references, $prefix = "") {
  518.  
  519.         $value = "";        
  520.         if (!isset($references[0])) {
  521.  
  522.             if (isset($references["group"]))
  523.                 $value .= sprintf('<a href="%s#%s_%s">%s::%s</a>',
  524.                                     $this->nameToUrl($references["group"]).$this->file_extension,
  525.                                     $references["type"],
  526.                                     $references["value"],
  527.                                     $references["group"],
  528.                                     $references["value"] 
  529.                             );
  530.             else 
  531.                 $value .= sprintf('<a href="#%s_%s">%s</a>',
  532.                                     $references["type"],
  533.                                     $references["value"],
  534.                                     $references["value"]
  535.                                 );
  536.  
  537.         } else {
  538.                 
  539.             reset($references);
  540.             while (list($k, $reference) = each($references)) {
  541.  
  542.                 if (isset($reference["group"]))
  543.                     $value .= sprintf('<a href="%s#%s_%s">%s::%s</a>, ',
  544.                                     $this->nameToUrl($reference["group"]).$this->file_extension,
  545.                                     $reference["type"],
  546.                                     $reference["value"],
  547.                                     $reference["group"],
  548.                                     $reference["value"] 
  549.                                 );
  550.                 else 
  551.                     $value .= sprintf('<a href="#%s_%s">%s</a>, ',
  552.                                         $reference["type"],
  553.                                         $reference["value"],
  554.                                         $reference["value"]
  555.                                     );
  556.  
  557.             }    
  558.  
  559.             $value = substr($value, 0, -2);
  560.         }
  561.  
  562.         $this->tpl->setCurrentBlock(strtolower($prefix) . "see");
  563.         $this->tpl->setVariable("SEE", $value);
  564.         $this->tpl->parseCurrentBlock();
  565.         
  566.     } // end func renderSee
  567.  
  568.     /**
  569.     * Renders an author list.
  570.     *
  571.     * @param    array   XML author array
  572.     * @param    string  optional template blockname prefix
  573.     */    
  574.     function renderAuthors($authors, $prefix = "") {
  575.  
  576.         $value = "";
  577.  
  578.         if (!isset($authors[0])) {
  579.  
  580.             if (isset($authors["email"]))
  581.                 $value .= sprintf('%s <<a href="mailto:%s">%s</a>>, ', $authors["value"], $authors["email"], $authors["email"]);
  582.             else 
  583.                 $value .= $authors["email"] . ", ";
  584.  
  585.         } else {
  586.  
  587.             reset($authors);
  588.             while (list($k, $author) = each($authors)) {
  589.  
  590.                 if (isset($author["email"]))
  591.                     $value .= sprintf('%s <<a href="mailto:%s">%s</a>>, ', $author["value"], $author["email"], $author["email"]);
  592.                 else 
  593.                     $value .= $author["email"] . ", ";
  594.  
  595.             }
  596.  
  597.         }
  598.  
  599.         $value = substr($value, 0, -2);
  600.         $this->tpl->setCurrentBlock(strtolower($prefix) . "authors");
  601.         $this->tpl->setVariable("AUTHOR", $value);
  602.         $this->tpl->parseCurrentBlock();
  603.  
  604.     } // end func renderAuthors
  605.  
  606.     /**
  607.     * Renders a list of external links.
  608.     *
  609.     * @param    array   XML link array
  610.     * @param    string  optional template blockname prefix
  611.     */
  612.     function renderLinks($links, $prefix = "") {
  613.  
  614.         $value = "";
  615.         if (!isset($links[0])) {
  616.             $value .= sprintf('<a href="%s">%s</a>%s, ', 
  617.                                 $links["url"], 
  618.                                 $links["url"], 
  619.                                 ("" != $links["description"]) ? " - " . $links["description"] : ""
  620.                             );
  621.         } else {
  622.  
  623.             reset($links);
  624.             while (list($k, $link) = each($links)) {
  625.                 $value .= sprintf('<a href="%s">%s</a>%s, ', 
  626.                                     $link["url"], 
  627.                                     $link["url"], 
  628.                                     ("" != $link["description"]) ? " - " . $links["description"] : ""
  629.                                 ); 
  630.             }
  631.  
  632.         }
  633.  
  634.         $value = substr($value, 0, 2);
  635.         $this->tpl->setCurrentBlock(strtolower($prefix) . "links");
  636.         $this->tpl->setVariable("LINK", $value);
  637.         $this->tpl->parseCurrentBlock();
  638.  
  639.     } // end func renderLinks
  640.  
  641.     /**
  642.     * Renders a list of exceptions.
  643.     *
  644.     * @param    array   XML array 
  645.     * @param    string  optional template blockname prefix
  646.     */
  647.     function renderThrows($throws, $prefix = "") {
  648.  
  649.         $value = "";
  650.         if (!isset($throws[0])) {
  651.         
  652.             $value = $throws["value"];
  653.             
  654.         }    else {
  655.  
  656.             reset($throws);
  657.             while (list($k, $exception) = each($throws)) 
  658.                 $value .= sprintf("%s, ", $exception["value"]);
  659.  
  660.             $value = substr($value, 0, -2);
  661.  
  662.         }    
  663.  
  664.         $this->tpl->setCurrentBlock(strtolower($prefix) . "throws");
  665.         $this->tpl->setVariable("EXCEPTIONS", $value);
  666.         $this->tpl->parseCurrentBlock();
  667.  
  668.     } // end func renderThrows
  669.  
  670.     /**
  671.     * Renders a list of global elements.
  672.     *
  673.     * @param    array   XML globals array
  674.     * @param    string  optional template blockname prefix
  675.     */
  676.     function renderGlobals($globals, $prefix = "") {
  677.  
  678.         $prefix = strtolower($prefix);
  679.         $this->tpl->setCurrentBlock($prefix . "globals_loop");
  680.  
  681.         if (!isset($globals[0])) {
  682.  
  683.             $this->tpl->setVariable("NAME", $globals["name"]);
  684.             $this->tpl->setVariable("DESCRIPTION", $this->encode($globals["value"]));
  685.  
  686.             if (isset($globals["type"]))
  687.                 $this->tpl->setVariable("TYPE", $globals["type"]);
  688.  
  689.             $this->tpl->parseCurrentBlock();
  690.  
  691.         } else {
  692.  
  693.             reset($globals);
  694.             while (list($k, $global) = each($globals)) {
  695.  
  696.                 $this->tpl->setVariable("NAME", $global["name"]);
  697.                 $this->tpl->setVariable("DESCRIPTION", $this->encode($global["value"]));
  698.  
  699.                 if (isset($globals["type"]))
  700.                     $this->tpl->setVariable("TYPE", $globals["type"]);
  701.  
  702.                 $this->tpl->parseCurrentBlock();
  703.  
  704.             }
  705.  
  706.         }
  707.  
  708.     } // end func renderGlobals
  709.  
  710.     /**
  711.     * Adds some tags to the template that are allowed nearly everywhere.
  712.     *
  713.     * @param    string  template blockname prefixs
  714.     * @param    array        
  715.     * @see    $simpleDocfields, renderLinks(), renderAuthors(), renderSee()
  716.     */    
  717.     function renderCommonDocfields($block, &$data) {
  718.  
  719.         reset($this->simpleDocfields);
  720.         while (list($varname, $field) = each($this->simpleDocfields)) {
  721.  
  722.             if (isset($data["doc"][$field])) {
  723.  
  724.                 $this->tpl->setCurrentBlock($block.$field);
  725.                 $this->tpl->setVariable($varname, htmlentities($data["doc"][$field]["value"]));
  726.                 $this->tpl->parseCurrentBlock();
  727.  
  728.             }
  729.  
  730.         }
  731.  
  732.         if (isset($data["doc"]["link"]))
  733.             $this->renderLinks($data["doc"]["link"], $block);
  734.  
  735.         if (isset($data["doc"]["author"])) 
  736.             $this->renderAuthors($data["doc"]["author"], $block);
  737.  
  738.         if (isset($data["doc"]["see"]))
  739.             $this->renderSee($data["doc"]["see"], $block);
  740.  
  741.     } // end func renderCommonDocfields
  742.  
  743. } // end func PhpdocHTMLDocumentRenderer
  744. ?>
  745.